<?php
/**
 * @filesource modules/event/controllers/IndexController.php
 * @author Dao Quang Duc
 * @abstract : List of actions in order
 *   - new
 *   - view
 *   - edit
 *   - delete
 *   - search
 */ 
class Event_IndexController extends Clu_Controller_Action_Hvn
{
	public $m,$c;//, $mPlace, $mArticle;
	
	public function init()
	{
		//require_once (APP_PATH.'/modules/place/Model/City.php');
		//require_once (APP_PATH.'/modules/place/Model/District.php');
		//require_once (APP_PATH.'/modules/place/Model/Village.php');
		//require_once (APP_PATH.'/modules/place/Model/Vicinity.php');
		//require_once (APP_PATH.'/modules/place/Model/Place.php');
		//require_once (APP_PATH.'/modules/category/Model/Category.php');
		//require_once (APP_PATH.'/modules/article/Model/Article.php');
		//require_once (APP_PATH.'/modules/user/Model/User.php');
		//require_once (APP_PATH.'/modules/comment/Model/Comment.php');
		$this->mArticle = new article_Model_Service();
		$this->m = new event_Model_Service();
		$this->mCategory = new category_Model_Category();
		$this->mPlace = new place_Model_Place();
		$this->mCity = new place_Model_City();
		
		parent::init();
		
	}
	
	public function newAction() 
	{
	   //check user permissions here
        $sess = new Zend_Session_Namespace(CLU_NS);
        if (strpos ($sess->userPermissions, 'create event') === false)
        {
            $this->view->errorMessage .= t(68);
            $this->renderToHolder( 'common/error.phtml');
            return;
        }
        //die_a($this->_request->getParams());
		//$placeId = $this->_request->getParam('belong_to_ids');
		$placeId = $this->_request->getParam('place_id');
		$form = new event_Form_Event();
        $form->cluBuild(array ('action' => 'new', 'view' => $this->view, 
										   'userPermissions' => $sess->userPermissions/*, 'place_id' => $placeId*/));
        if ($placeId)
		{   
	        $this->view->place_id = $placeId;
	        $this->view->belong_to_names_submit = $this->_request->getParam('belong_to_names_submit');
	        $placeData = $this->mPlace->findByPrimary($placeId);
	        $cityName = unserialize($placeData['metadata']);
	        $this->view->cityName = $cityName['city_name'];
	        $a = array();
	        $keys = array('city_id', 'district_id', 'village_id', 'address5', 'address6', 'address7', 'address8', 'address9');
	        $a = clu_array_merge($keys, $placeData);
	        $form->populate($a);
	        $form->populateEventForm($a);
		}
        $this->view->mode = "new";
        $this->view->form = $form;
    	$data = $this->_request->getParams();
        if ($this->_request->isPost() && $form->isValid($_POST)) 
        {
        	$db = $this->db;
	        $db->beginTransaction(); //TODO: to be moved to Model in v2
            try 
            {
            	$data['article_title'] 		= $data['title'];
            	$data['article_body']  		= $data['description'];
            	$data['article_language'] 	= $data['eventLanguage'];
            	$data['article_module'] 	= "event";
            	$data['article_keywords'] 	= $data['keywords'];
            	$data['article_status'] 	= isset($data['status']) ? $data['status'] : 
            		Zend_Registry::get('configuration')->general->defaultNodeStatus;
            	//die_a($placeId);
                if (!$this->mArticle->insertRaw($data,false))
                if (!$this->mArticle->insertRaw($data,array('do_validate' => false)))
                {
                	$this->view->errorMessage .= t(503);
                }
                $article_id = $db->lastInsertId();
            	$data['article_id'] = $article_id;
    			if($article_id != 0)
                {
		            try
			    	{
			    	   	$eventId = $this->m->insertRaw($data,array('do_validate' => false));
			            if(isset($data['belong_to_ids']))
			            	$this->mPlace->relatedEvent($data['belong_to_ids'], $eventId, null);
			    	}
			    	catch (Exception $e) 
			    	{
			    		die($e->getMessage());
			    	    $this->view->errorMessage .= t(214);
			    		$this->mArticle->deleteByPrimary(array($article_id), false);
			    	}
                }
                $db->commit();
            }
            catch (Exception $e)
            {
                $db->rollBack();
                $this->view->errorMessage .= "<br/>" . t(69);
            }
	    	
            if (empty($this->view->errorMessage))
            {
            	$url = $this->view->hvnUrl(array('module'=>'event', 'action'=>'gallery'));
    			$this->_helper->redirector->gotoUrl($url . '?id='.$eventId); //TODO
//				$this->_forward("success", 'index' , 'event', array('lastInsertId' => $article_id, 'lang' => 'en' ) );
    	    	return;
            }
            
        }
        else if ($this->_request->isPost() )
        {
        	$this->view->errorMessage = t(1);
        }
        //Populate form & rtype options 
        $categoryId = $this->_request->getParam("category");
        $form->populateEventForm( $data);
        
        $loginRequest = array(
                                'module' => 'user',
                                'controller' => 'block',
                                'action' => 'login',
                                'regionId' => 1,
                                'boxWeight' => 1,
								'theme' => 'second'
                );
		$this->addMiniAction($loginRequest);
		
		$eventSimpleSearchRequest = array(
				'module' => 'event',
				'controller' => 'block',
				'action' => 'simpleSearch',
				'regionId' => 3,
				'boxWeight' => 1,
		);
		$this->addMiniAction($eventSimpleSearchRequest);
		
		$subMenuRequest = array(
				'module' => 'place',
				'controller' => 'block',
				'action' => 'subMenu',
				'regionId' => 3,
				'boxWeight' => 2,
				'page' => 'event',
		);
		$this->addMiniAction($subMenuRequest);
		
		$upcomingEventRequest = array(
                                'module' => 'event',
                                'controller' => 'block',
                                'action' => 'upcomingEvent',
                                'regionId' => 6,
                                'boxWeight' => 1,
                );
		$this->addMiniAction($upcomingEventRequest);
		         
		
		$OnlineSupportRequest = array(
				'module' => 'hvn',
				'controller' => 'block',
				'action' => 'onlineSupport',
				'regionId' => 5,
				'boxWeight' => 2,
		);
		$this->addMiniAction($OnlineSupportRequest);
		
		$infoSupportRequest = array(
				'module' => 'common',
				'controller' => 'block',
				'action' => 'infoSupport',
				'regionId' => 5,
				'boxWeight' => 3,
		);
		$this->addMiniAction($infoSupportRequest); 
		
        $this->renderToHolder('index/new.phtml'); 
	}
	
	public function viewAction() 
	{
		$id = $this->_request->getParam("id");
    	$e = $this->m->findByPrimary($id);
		 if(!$event = $this->m->getData($id,array('get_article' => true)))
        {
            $this->view->errorMessage = t(209);
            $this->renderToHolder( 'common/error.phtml', false, null, 4, 1);	
            return;
        }
	 	$sess = new Zend_Session_Namespace(CLU_NS);
        if ($event['article']->article_language != $sess->viewLang)
            $this->view->errorMessage = sprintf(t(519),  $sess->viewLang );
            							   
        if (strpos ($sess->userPermissions, 'read event') === false)
        {
            $this->view->errorMessage .= t(70);
            $this->renderToHolder( 'common/error.phtml');
            return;
        }
		$this->view->lang = $sess->viewLang;
        $this->view->oriLang = $event['article']->article_language;
        $this->view->articleBody = $event['article']->article_body;
        $this->view->event = $this->m->transformToFormArray('edit',$e);
        $this->renderToHolder('index/view.phtml', false, null, 4, 1); 
        
        $loginRequest = array(
                                'module' => 'user',
                                'controller' => 'block',
                                'action' => 'login',
                                'regionId' => 1,
                                'boxWeight' => 1,
								'theme' => 'second'
                );
		$this->addMiniAction($loginRequest);
		
		$eventSimpleSearchRequest = array(
				'module' => 'event',
				'controller' => 'block',
				'action' => 'simpleSearch',
				'regionId' => 3,
				'boxWeight' => 1,
		);
		$this->addMiniAction($eventSimpleSearchRequest);
		
//		$subMenuRequest = array(
//				'module' => 'place',
//				'controller' => 'block',
//				'action' => 'subMenu',
//				'regionId' => 3,
//				'boxWeight' => 2,
//				'page' => 'event',
//		);
//		$this->addMiniAction($subMenuRequest);
		
        $tabMenuRequest = array(
                                'module' => 'place',
                                'controller' => 'block',
                                'action' => 'tabMenu',
                                'regionId' => 4,
                                'boxWeight' => 2,
                                'page' => 'view-event',
                );
		$this->addMiniAction($tabMenuRequest);
		
		$listRestaurantRequest = array(
					'module' => 'event',
					'controller' => 'block',
					'action' => 'listComment',
					'regionId' => 4,
					'boxWeight' => 3,
			);
		$this->addMiniAction($listRestaurantRequest);
		
		
//		$commentRequest = array(
//        						'module' => 'comment',
//        						'controller' => 'block',
//        						'action' => 'moduleComment',
//        						'regionId' => 4,
//        						'boxWeight' => 6,
//        						'id' => $id,
//        						'comments_per_page' => 10,
//        						'page_number' => 1,
//        						'parent_content_type' => 'event' 
//        						);
//        $this->addMiniAction($commentRequest);	
        
		
        //block gallery 
//		$galleryRequest = array(
//				'module' => 'file',
//				'controller' => 'block',
//				'action' => 'imageList',
//				'regionId' => 6,
//				'boxWeight' => 1,
//				'poster_id' => $e['poster_id'],
//				'c' => 'event',
//				't' => 'image',
//				'uid' => $e['poster_id'],
//				'id'  => $e['id'],
//				'galleryId' => 'gallery-event-' . $e['id'],
//				
//		);
//		$this->addMiniAction($galleryRequest);
		
		$upcomingEventRequest = array(
                                'module' => 'event',
                                'controller' => 'block',
                                'action' => 'upcomingEvent',
                                'regionId' => 6,
                                'boxWeight' => 1,
                );
		$this->addMiniAction($upcomingEventRequest);
		         
		
		$OnlineSupportRequest = array(
				'module' => 'hvn',
				'controller' => 'block',
				'action' => 'onlineSupport',
				'regionId' => 5,
				'boxWeight' => 2,
		);
		$this->addMiniAction($OnlineSupportRequest);
		
		$infoSupportRequest = array(
				'module' => 'common',
				'controller' => 'block',
				'action' => 'infoSupport',
				'regionId' => 5,
				'boxWeight' => 3,
		);
		$this->addMiniAction($infoSupportRequest);          
		
	}
	
	public function editAction()
	{
        $sess = new Zend_Session_Namespace(CLU_NS);
    	$id = $this->_request->getParam("id");
    	if (!$e = $this->m->findByPrimary($id))
        {              
            $this->view->errorMessage .= t(209);
            $this->renderToHolder('common/error.phtml');
            return;
        }
        
		//check for permission here
		//check rights
        $auth = Zend_Auth::getInstance();
        if (!$auth->hasIdentity())
		{
		 	$this->view->errorMessage .= t(210);
            $this->renderToHolder('common/error.phtml');
            return;
		}
		$uIdentity = $auth->getIdentity();
		//if not admin
		// or not owner
		if (($uIdentity->id != $e->poster_id && strpos ($sess->userPermissions, 'update event') === false) ||
			($uIdentity->id == $e->poster_id && strpos ($sess->userPermissions, 'update own event') === false))
		{
		 	$this->view->errorMessage .= t(210);
            $this->renderToHolder('common/error.phtml');
            return;
		}        
        
        //everything's fine. Continue editing
        $form = new event_Form_Event();
        $form->cluBuild(array ('action' => 'edit','view' => $this->view, 
							   'userPermissions' => $sess->userPermissions, 'place_id' => $e['place_id']));
        
        /*
		if(isset($e['place_id']))
		{
			$dataPlace = unserialize($e['metadata']);
			$this->view->placeData = $dataPlace;
		}
		*/
        
        if ($form->isValid($_POST))
        {	
			$data = $this->_request->getParams();
        	$articleData = array();
            $articleData['article_title'] = $data['title'];
            $articleData['article_body'] = $data['description'];
            $article_id = $data['article_id'];
            if (!($this->mArticle->saveRaw(null, $articleData, $article_id,array('do_validate' => false))))
            {
            	$this->view->errorMessage .= t(503);
            }
            
            if($e->place_id != $data['belong_to_ids'])
        	{
        		$this->mPlace->relatedEvent($data['belong_to_ids'], $id, $e->place_id);
        	}
        	
            if ($this->m->saveRaw($e, $data, $id, array('do_validate' => false)))
            {
    		 	$this->view->successMessage .= t(211);
    		 	$form->populateEventForm ($e);
            }
            else
                $this->view->errorMessage .= t(212);
        }
        else
        { 
        	$this->view->errorMessage .= t(71);
            //Populate form 
	        $form->populateEventForm ($e);
        }
		
		$fData = unserialize($e->metadata);
        if(isset($e->place_id) && isset($fData['place_name']))
        {
	        $this->view->place_id = $e->place_id;
        	$this->view->belong_to_names_submit = $fData['place_name'];
        	$this->view->cityName = $fData['city_name'];
        }
        
        $this->view->form = $form;
		$this->view->article_id = $e['article_id'];
        $this->view->id = $id;
        $this->view->mode = 'edit';
        $this->view->lang = Zend_Registry::get('viewLang');
        
        $loginRequest = array(
                                'module' => 'user',
                                'controller' => 'block',
                                'action' => 'login',
                                'regionId' => 1,
                                'boxWeight' => 1,
								'theme' => 'second'
                );
		$this->addMiniAction($loginRequest);
		
		$eventSimpleSearchRequest = array(
				'module' => 'event',
				'controller' => 'block',
				'action' => 'simpleSearch',
				'regionId' => 3,
				'boxWeight' => 1,
		);
		$this->addMiniAction($eventSimpleSearchRequest);
		
        $upcomingEventRequest = array(
                                'module' => 'event',
                                'controller' => 'block',
                                'action' => 'upcomingEvent',
                                'regionId' => 6,
                                'boxWeight' => 1,
                );
		$this->addMiniAction($upcomingEventRequest);
		         
		
		$OnlineSupportRequest = array(
				'module' => 'hvn',
				'controller' => 'block',
				'action' => 'onlineSupport',
				'regionId' => 5,
				'boxWeight' => 2,
		);
		$this->addMiniAction($OnlineSupportRequest);
		
		$infoSupportRequest = array(
				'module' => 'common',
				'controller' => 'block',
				'action' => 'infoSupport',
				'regionId' => 5,
				'boxWeight' => 3,
		);
		$this->addMiniAction($infoSupportRequest);  
		
        $this->renderToHolder('index/new.phtml', false, null, 4, 1);    
	}

	public function searchAction()
    {
    	//unset($_SESSION['paginator']);
    	$data = $this->_request->getParams();
    	$sess = new Zend_Session_Namespace(CLU_NS);
    	
		if (strpos($sess->userPermissions, "administer event"))
			$cluSearchMode = "fullAdminSearch";
	    else
			$cluSearchMode = "fullSearch";
		
      	$form = new event_Form_EventSearch();
      	$form->cluBuild(array ('view' => $this->view, 'cluSearchMode' => $cluSearchMode));
        $this->view->form = $form;
		if (isset($data['clu_search']) || $this->_request->isPost())
		{
			if(isset($data['quick_time_range_mode']))
    			{
    				switch($data['quick_time_range_mode'])
    				{
    					case 1:
    					{
    						$data['startDate'] = date("d/m/Y",time());
    						$data['finishDate'] = date("d/m/Y",time() + 604800); // 604800s = 7days
    						break;
    					}
    					
    					case 2:
    					{
    						$data['startDate'] = date("d/m/Y",time());
    						$data[ 'finishDate'] = date("d/m/Y",time() + 2592000); // 2592000s = 30days
    						break;
    					}
    					
    					case 3:
    					{
    						$data['startDate'] = date("d/m/Y",time());
    						$data[ 'finishDate'] = date("d/m/Y",time() + 7776000); // 7776000s = 90days
    						break;
    					}
    				}
    				$data['quick_time_range_mode'] = NULL;
    			}
			//place list + pagination
	       	if (!isset($data['events_per_page']))
    			$data['events_per_page'] = 10;
    		if (!isset($data['page']))
    			$data['page'] = 1;
    			
	    	if($paginator = $this->m->search($data))
    		{
    			$paginator= $this->generatePaginator($paginator, $data['page'], $data['events_per_page'], 7, 'Jumping');
                $form->populate($data);  //$data['events_per_page']
    			
        	}
			//cache in $_SESSION
           	$sessPaginator = new Zend_Session_Namespace("event_paginator");
            $sessPaginator->event_search_params = array("search_params" => $data); 
		}
        else if(!empty($data['page'])){
			$sessPaginator  = new Zend_Session_Namespace("event_paginator");
        	$data = $sessPaginator->event_search_params;
           	if(isset($data))
           	{
               $select = $this->m->search($data['search_params']);
               $paginator = $this->generatePaginator($select, $this->_getParam('page'), $data['search_params']['events_per_page'], 3, 'Jumping');
               //populate form
               $form->populate($data['search_params']);
           	}
        }

        if(isset($paginator))
       	{                
            $this->view->paginator = $paginator;
        	foreach($paginator->getCurrentItems() as $temp)
        	{
            	$tmp = $this->m->transformToFormArray('edit',$temp);
        		$List[] = $tmp;
        	}
        	
            if (isset($List))
            {
    			$this->view->eventList = $List;//list of found events
				$articleList = array();
				$mArticle = new article_Model_Service();
				foreach ($this->view->eventList as $e)
				{
					$articleList[$e['id']] = $mArticle->getArticleData($e['article_id']);
				}
				$this->view->aList = $articleList;
	
				$t = $this->_request->getParam('page');
				$pageNum  = !empty($t) ? $t : 1; 
				$perPage = isset($data['events_per_page']) ? $data['events_per_page']:  $data['search_params']['events_per_page'];
				$this->view->startIndex = $perPage * ($pageNum - 1);
				$this->view->numberOfItems = $paginator->getTotalItemCount();
				$this->view->perPage = $perPage;
				$this->view->pageNum = $pageNum;
				$this->view->numberOfPages = ceil($this->view->numberOfItems/$this->view->perPage);  
		       	//$this->renderToHolder('index/list_admin.phtml');
		       	//$this->renderToHolder('index/list.phtml', false, 4,2);    			
            }
            if (strpos($sess->userPermissions, "administer event"))
	            $this->renderToHolder('index/list_admin.phtml',false, null, 4,2);
	        else
	        	$this->renderToHolder('index/list.phtml',false, null, 4,2);
       	}
       	//$this->view->lang = Zend_Registry::get('viewLang');
       	$this->renderToHolder('index/'.$cluSearchMode . '.phtml',false, null, 4,1); //search box
		
		$loginRequest = array(
                                'module' => 'user',
                                'controller' => 'block',
                                'action' => 'login',
                                'regionId' => 1,
                                'boxWeight' => 1,
								'theme' => 'second'
                );
		$this->addMiniAction($loginRequest);
		
		$eventSimpleSearchRequest = array(
				'module' => 'event',
				'controller' => 'block',
				'action' => 'simpleSearch',
				'regionId' => 3,
				'boxWeight' => 1,
		);
		$this->addMiniAction($eventSimpleSearchRequest);
		
//		$subMenuRequest = array(
//				'module' => 'place',
//				'controller' => 'block',
//				'action' => 'subMenu',
//				'regionId' => 3,
//				'boxWeight' => 2,
//				'page' => 'event',
//		);
//		$this->addMiniAction($subMenuRequest);
		
		$OnlineSupportRequest = array(
				'module' => 'hvn',
				'controller' => 'block',
				'action' => 'onlineSupport',
				'regionId' => 5,
				'boxWeight' => 2,
		);
		$this->addMiniAction($OnlineSupportRequest);
		
		$infoSupportRequest = array(
				'module' => 'common',
				'controller' => 'block',
				'action' => 'infoSupport',
				'regionId' => 5,
				'boxWeight' => 3,
		);
		$this->addMiniAction($infoSupportRequest);
		
		$upcomingEventRequest = array(
                                'module' => 'event',
                                'controller' => 'block',
                                'action' => 'upcomingEvent',
                                'regionId' => 6,
                                'boxWeight' => 1,
                );
		$this->addMiniAction($upcomingEventRequest);
		
		/*
        //todo: just sample to test layout. to be removed
		$placeBrowseByCategoriesRequest = array(
				'module' => 'place',
				'controller' => 'block',
				'action' => 'browseByCategory',
				'regionId' => 5,
				'boxWeight' => 1,
		);
		$this->addMiniAction($placeBrowseByCategoriesRequest);
		
		$eventBrowseByCategoriesRequest = array(
                                'module' => 'event',
                                'controller' => 'block',
                                'action' => 'browseByCategory',
                                'regionId' => 5,
                                'boxWeight' => 0,
                );
        $this->addMiniAction($eventBrowseByCategoriesRequest);
       */   
        
    }
	   
	public function generatePaginator($select, $pageNumber, $itemsPerPage, $pageRange, $style)
    {
        $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($select));
        $paginator->setItemCountPerPage($itemsPerPage);
        $paginator->setCurrentPageNumber($pageNumber);
        $paginator->setPageRange($pageRange);
        Zend_Paginator::setDefaultScrollingStyle($style);
        return $paginator;
    }

	public function successAction()
    {
         $this->view->commentId =  $this->_request->getParam("lastInsertId");
         $this->renderToHolder( 'common/success.phtml');  
    }
    
    public function galleryAction()
    {
        $eventId = $this->_request->getParam("id");
        $p = $this->m->findByPrimary($eventId, true);
        $auth = Zend_Auth::getInstance();
       	$uIdentity = $auth->getIdentity();
        if (!$p)
        {
        	$this->view->errorMessage .= t(213);
            $this->renderToHolder( 'common/error.phtml');
            return;
        }
        $this->view->id = $eventId;
        if(!empty($uIdentity))
        	$this->view->uid = $uIdentity->id;
        $this->renderToHolder( 'index/gallery.phtml');                 
    }
    
   	public function homeAction()
	{
		$sess = new Zend_Session_Namespace(CLU_NS);
		
		$loginRequest = array(
                                'module' => 'user',
                                'controller' => 'block',
                                'action' => 'login',
                                'regionId' => 1,
                                'boxWeight' => 1,
								'theme' => 'second'
                );
		$this->addMiniAction($loginRequest);
		
		$eventSimpleSearchRequest = array(
				'module' => 'event',
				'controller' => 'block',
				'action' => 'simpleSearch',
				'regionId' => 3,
				'boxWeight' => 1,
		);
		$this->addMiniAction($eventSimpleSearchRequest);
		
		$subMenuRequest = array(
				'module' => 'place',
				'controller' => 'block',
				'action' => 'subMenu',
				'regionId' => 3,
				'boxWeight' => 2,
				'page' => 'event',
		);
		$this->addMiniAction($subMenuRequest);

		$placeRequest = array(
                                'module' => 'event',
                                'controller' => 'block',
                                'action' => 'featuredListHome',
                                'regionId' => 4,
                                'boxWeight' => 1,
								'page' => 'home'
                );
		$this->addMiniAction($placeRequest);
		
		$advertiseRequest = array(
                                'module' => 'place',
                                'controller' => 'block',
                                'action' => 'advertise',
                                'regionId' => 4,
                                'boxWeight' => 2,
                                'page' => 'event',
                );
		$this->addMiniAction($advertiseRequest);
		
		$listNatureRequest = array(
					'module' => 'place',
					'controller' => 'block',
					'action' => 'listNature',
					'regionId' => 4,
					'boxWeight' => 3,
					'rtype' => array(17,18,20,21),
					'page' => 'place',
			);
		$this->addMiniAction($listNatureRequest);
		
		/*
        //todo: just sample to test layout. to be removed
		$placeBrowseByCategoriesRequest = array(
				'module' => 'place',
				'controller' => 'block',
				'action' => 'browseByCategory',
				'regionId' => 5,
				'boxWeight' => 0,
		);
		$this->addMiniAction($placeBrowseByCategoriesRequest);
       */
        $mapRequest = array(
                            'module' => 'hvn',
                            'controller' => 'block',
                            'action' => 'mapVietnam',
                            'regionId' => 6,
                            'boxWeight' => 1,
                );
		$this->addMiniAction($mapRequest);
		
		$OnlineSupportRequest = array(
				'module' => 'hvn',
				'controller' => 'block',
				'action' => 'onlineSupport',
				'regionId' => 5,
				'boxWeight' => 2,
		);
		$this->addMiniAction($OnlineSupportRequest);
		
		$infoSupportRequest = array(
				'module' => 'common',
				'controller' => 'block',
				'action' => 'infoSupport',
				'regionId' => 5,
				'boxWeight' => 3,
		);
		$this->addMiniAction($infoSupportRequest);
		
	}
    
}

/* //search multi frequency .So difficult :|	
	public function searchAction()
    {
    	$data = $this->_request->getParams();
//    	die_a($data);
      	$form = new event_Form_EventSearch();
      	$form->cluBuild(array ('view' => $this->view));
        $this->view->form = $form; 
		if($this->_request->isPost() && $form->isValid($_POST))
		{
			if ($data['frequency'] == 'all')
    		$frequencies = array('once', 'daily', 'weekly', 'monthly', 'yearly');
    		else
    		$frequencies = array($data['frequency']); //in case user chose 'once' & 'daily' 
    
//    		die_a($frequencies);
    		foreach ($frequencies as $f)
    		{
    			$tmp = $data['frequency'];
    			$data['frequency'] = $f ;
//    			die_a($data);
    	    	if($paginator = $this->m->search($data))
        		{
        			$paginatorList[] = $this->generatePaginator($paginator, 1, $data['events_per_page'], 3, 'Jumping');
                    $form->populate($data);  //$data['events_per_page']
        			
            	}
    		}
//    			die_a($i);
//    			die_a($data['events_per_page']);
    			$data['frequency'] = $tmp;	
    			//cache in $_SESSION
               	$sess = new Zend_Session_Namespace("event_paginator");
                $sess->event_search_params = array("search_params" => $data); 
//                    die_a($paginator);
//                    die_a($sess->event_search_params);
		}
        else if(!empty($data['page']) && $data['page'] != null){
			$sess = new Zend_Session_Namespace("event_paginator");
        	$data = $sess->event_search_params;
//    		die_a($data);
           	if(isset($data))
           	{
               $select = $this->m->search($data['search_params']);
               $paginator = $this->generatePaginator($select, $this->_getParam('page'), 5, 3, 'Jumping');//$data['search_params']['events_per_page']
//               die_a($paginator);
               //populate form
               $form->populate($data['search_params']);
           	}
        }

        if(isset($paginatorList))
       	{                
            $this->view->paginator = $paginatorList;
            foreach($paginatorList as $list => $paginator)
            {
            	foreach($paginator->getCurrentItems() as $temp)
            	{
//            		die($temp['frequency']);
	            	$tmp = $this->m->transformToFormArray($temp,false);
            		$List[$temp['frequency']][] = $tmp;
            	}
//            		die_a($temp);
            }
//            die_a($List);	
            if (isset($List))
    			$this->view->eventList = $List;
//    		die_a($this->view->paginator);
//    		$this->view->eventList = $paginator->getCurrentItems();//list of found events
            $this->renderToHolder('index/list.phtml',false, 4,2); 
       	}
       	$this->view->lang = Zend_Registry::get('viewLang');
        $this->renderToHolder('index/search.phtml',false, 4,1); //search box 
    }
 */
	
?>
